/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.generator.builder;

import ru.jSkyRoom.generator.builder.ruleBuilder.EnchantmentionGeneratorRuleBuilder;
import java.util.ArrayList;
import java.util.Collection;
import ru.jSkyRoom.generator.SimpleItemsGenerator;
import ru.jSkyRoom.generator.command.rule.Rule;
import ru.jSkyRoom.interfaces.major.Enchantment;
import ru.jSkyRoom.interfaces.JSkyMod;
import ru.jSkyRoom.interfaces.major.Major;

/**
 *
 * @author Rakev
 */
public class EnchantmentionGeneratorBuilder<T extends Major> {

    private JSkyMod editingMod;
    private Collection<EnchantmentionGeneratorRuleBuilder> ruleBuilders = new ArrayList<>();

    public EnchantmentionGeneratorBuilder(JSkyMod editingMod) {
        this.editingMod = editingMod;
    }

    public EnchantmentionGeneratorRuleBuilder createRuleBuilder(Enchantment enchantment) {
        EnchantmentionGeneratorRuleBuilder ruleBuilder = new EnchantmentionGeneratorRuleBuilder(editingMod, enchantment);
        ruleBuilders.add(ruleBuilder);
        return ruleBuilder;
    }

    public SimpleItemsGenerator<T> build() {
        Collection<Rule<T>> buildedRules = new ArrayList<>(ruleBuilders.size());
        for (EnchantmentionGeneratorRuleBuilder ruleBuilder : ruleBuilders) {
            buildedRules.add(ruleBuilder.build());
        }
        return new SimpleItemsGenerator<>(buildedRules);
    }
}
